home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270_src.lha / gcc-2.7.0-amiga / config / i370 / mvs.h < prev    next >
C/C++ Source or Header  |  1995-06-15  |  49KB  |  1,496 lines

  1. /* Definitions of target machine for GNU compiler.  System/370 version.
  2.    Copyright (C) 1989, 1993, 1995 Free Software Foundation, Inc.
  3.    Contributed by Jan Stein (jan@cd.chalmers.se).
  4.    Modified for C/370 MVS by Dave Pitts (pitts@mcdata.com)
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2, or (at your option)
  11. any later version.
  12.  
  13. GNU CC is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with GNU CC; see the file COPYING.  If not, write to
  20. the Free Software Foundation, 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.  */
  22.  
  23. #ifdef sun
  24. #include <sys/types.h>
  25. #include <ctype.h>
  26. #endif
  27. #include <time.h>
  28.  
  29. #define TARGET_VERSION printf (" (370/MVS)");
  30.  
  31. /* Names to predefine in the preprocessor for this target machine.  */
  32.  
  33. #define CPP_PREDEFINES "-DGCC -Dgcc -DMVS -Dmvs -Asystem(mvs) -Acpu(i370) -Amachine(i370)"
  34.  
  35. /* Run-time compilation parameters selecting different hardware subsets.  */
  36.  
  37. extern int target_flags;
  38.  
  39. /* The sizes of the code and literals on the current page.  */
  40.  
  41. extern int mvs_page_code, mvs_page_lit;
  42.  
  43. /* The current page number and the base page number for the function.  */
  44.  
  45. extern int mvs_page_num, function_base_page;
  46.  
  47. /* True if a label has been emitted.  */
  48.  
  49. extern int mvs_label_emited;
  50.  
  51. /* The name of the current function.  */
  52.  
  53. extern char *mvs_function_name;
  54.  
  55. /* The length of the function name malloc'd area.  */
  56.  
  57. extern int mvs_function_name_length;
  58.  
  59. /* The amount of space used for outgoing arguments.  */
  60.  
  61. extern int current_function_outgoing_args_size;
  62.  
  63. /* Compile using char instructions (mvc, nc, oc, xc).  On 4341 use this since
  64.    these are more than twice as fast as load-op-store.
  65.    On 3090 don't use this since load-op-store is much faster.  */
  66.  
  67. #define TARGET_CHAR_INSTRUCTIONS (target_flags & 1)
  68.  
  69. /* Default target switches */
  70.  
  71. #define TARGET_DEFAULT 1
  72.  
  73. /* Macro to define tables used to set the flags.  This is a list in braces
  74.    of pairs in braces, each pair being { "NAME", VALUE }
  75.    where VALUE is the bits to set or minus the bits to clear.
  76.    An empty string NAME is used to identify the default VALUE.  */
  77.  
  78. #define TARGET_SWITCHES                            \
  79. { { "char-instructions", 1},                        \
  80.   { "no-char-instructions", -1},                    \
  81.   { "", TARGET_DEFAULT} }
  82.  
  83. /* Target machine storage layout */
  84.  
  85. /* Define this if most significant bit is lowest numbered in instructions
  86.    that operate on numbered bit-fields.  */
  87.  
  88. #define BITS_BIG_ENDIAN 1
  89.  
  90. /* Define this if most significant byte of a word is the lowest numbered.  */
  91.  
  92. #define BYTES_BIG_ENDIAN 1
  93.  
  94. /* Define this if MS word of a multiword is the lowest numbered.  */
  95.  
  96. #define WORDS_BIG_ENDIAN 1
  97.  
  98. /* Number of bits in an addressable storage unit.  */
  99.  
  100. #define BITS_PER_UNIT 8
  101.  
  102. /* Width in bits of a "word", which is the contents of a machine register.  */
  103.  
  104. #define BITS_PER_WORD 32
  105.  
  106. /* Width of a word, in units (bytes).  */
  107.  
  108. #define UNITS_PER_WORD 4
  109.  
  110. /* Width in bits of a pointer.  See also the macro `Pmode' defined below.  */
  111.  
  112. #define POINTER_SIZE 32
  113.  
  114. /* Allocation boundary (in *bits*) for storing pointers in memory.  */
  115.  
  116. #define POINTER_BOUNDARY 32
  117.  
  118. /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
  119.  
  120. #define PARM_BOUNDARY 32
  121.  
  122. /* Boundary (in *bits*) on which stack pointer should be aligned.  */
  123.  
  124. #define STACK_BOUNDARY 32
  125.  
  126. /* Allocation boundary (in *bits*) for the code of a function.  */
  127.  
  128. #define FUNCTION_BOUNDARY 32
  129.  
  130. /* There is no point aligning anything to a rounder boundary than this.  */
  131.  
  132. #define BIGGEST_ALIGNMENT 64
  133.  
  134. /* Alignment of field after `int : 0' in a structure.  */
  135.  
  136. #define EMPTY_FIELD_BOUNDARY 32
  137.  
  138. /* Define this if move instructions will actually fail to work when given
  139.    unaligned data.  */
  140.  
  141. #define STRICT_ALIGNMENT 0
  142.  
  143. /* Define target floating point format.  */
  144.  
  145. #define TARGET_FLOAT_FORMAT IBM_FLOAT_FORMAT
  146.  
  147. /* Define character mapping for cross-compiling.  */
  148.  
  149. #define TARGET_EBCDIC 1
  150.  
  151. #ifdef HOST_EBCDIC
  152. #define MAP_CHARACTER(c) ((char)(c))
  153. #else
  154. #define MAP_CHARACTER(c) ((char)mvs_map_char (c))
  155. #endif
  156.  
  157. /* Define maximum length of page minus page escape overhead.  */
  158.  
  159. #define MAX_MVS_PAGE_LENGTH 4080
  160.  
  161. /* Define if special allocation order desired.  */
  162.  
  163. #define REG_ALLOC_ORDER                            \
  164. { 0, 1, 2, 3, 14, 15, 12, 10, 9, 8, 7, 6, 5, 4, 16, 17, 18, 19, 11, 13 }
  165.  
  166. /* Standard register usage.  */
  167.  
  168. /* Number of actual hardware registers.  The hardware registers are
  169.    assigned numbers for the compiler from 0 to just below
  170.    FIRST_PSEUDO_REGISTER.
  171.    All registers that the compiler knows about must be given numbers,
  172.    even those that are not normally considered general registers.
  173.    For the 370, we give the data registers numbers 0-15,
  174.    and the floating point registers numbers 16-19.  */
  175.  
  176. #define FIRST_PSEUDO_REGISTER 20
  177.  
  178. /* Define base and page registers.  */
  179.  
  180. #define BASE_REGISTER 3
  181. #define PAGE_REGISTER 4
  182.  
  183. /* 1 for registers that have pervasive standard uses and are not available
  184.    for the register allocator.  On the 370 under C/370, R13 is stack (DSA)
  185.    pointer, R12 is the TCA pointer, R3 is the base register, R4 is the page
  186.    origin table pointer and R11 is the arg pointer.  */
  187.  
  188. #define FIXED_REGISTERS                         \
  189. { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0 }
  190. /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19*/
  191.  
  192. /* 1 for registers not available across function calls.  These must include
  193.    the FIXED_REGISTERS and also any registers that can be used without being
  194.    saved.
  195.    The latter must include the registers where values are returned
  196.    and the register where structure-value addresses are passed.
  197.    NOTE: all floating registers are undefined across calls.  */
  198.  
  199. #define CALL_USED_REGISTERS                         \
  200. { 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
  201. /*0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19*/
  202.  
  203. /* Return number of consecutive hard regs needed starting at reg REGNO
  204.    to hold something of mode MODE.
  205.    This is ordinarily the length in words of a value of mode MODE
  206.    but can be less for certain modes in special long registers.  */
  207.  
  208. #define HARD_REGNO_NREGS(REGNO, MODE)                     \
  209.   ((REGNO) > 15 ? 1 : (GET_MODE_SIZE(MODE)+UNITS_PER_WORD-1) / UNITS_PER_WORD)
  210.  
  211. /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
  212.    On the 370, the cpu registers can hold QI, HI, SI, SF and DF.  The
  213.    even registers can hold DI.  The floating point registers can hold
  214.    either SF or DF.  */
  215.  
  216. #define HARD_REGNO_MODE_OK(REGNO, MODE)                    \
  217.   ((REGNO) < 16 ? ((REGNO) & 1) == 0 || (MODE) != DImode        \
  218.         : (MODE) == SFmode || (MODE) == DFmode)
  219.  
  220. /* Value is 1 if it is a good idea to tie two pseudo registers when one has
  221.    mode MODE1 and one has mode MODE2.
  222.    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
  223.    for any hard reg, then this must be 0 for correct output.  */
  224.  
  225. #define MODES_TIEABLE_P(MODE1, MODE2)                    \
  226.   (((MODE1) == SFmode || (MODE1) == DFmode)                \
  227.    == ((MODE2) == SFmode || (MODE2) == DFmode))
  228.  
  229. /* Mark external references.  */
  230.  
  231. #define ENCODE_SECTION_INFO(decl)                      \
  232.   if (DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))             \
  233.     SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
  234.  
  235. /* Specify the registers used for certain standard purposes.
  236.    The values of these macros are register numbers.  */
  237.  
  238. /* 370 PC isn't overloaded on a register.  */
  239.  
  240. /* #define PC_REGNUM */
  241.  
  242. /* Register to use for pushing function arguments.  */
  243.  
  244. #define STACK_POINTER_REGNUM 13
  245.  
  246. /* Base register for access to local variables of the function.  */
  247.  
  248. #define FRAME_POINTER_REGNUM 13
  249.  
  250. /* Value should be nonzero if functions must have frame pointers.
  251.    Zero means the frame pointer need not be set up (and parms may be
  252.    accessed via the stack pointer) in functions that seem suitable.
  253.    This is computed in `reload', in reload1.c.  */
  254.  
  255. #define FRAME_POINTER_REQUIRED 1
  256.  
  257. /* Base register for access to arguments of the function.  */
  258.  
  259. #define ARG_POINTER_REGNUM 11
  260.  
  261. /* Register in which static-chain is passed to a function.  */
  262.  
  263. #define STATIC_CHAIN_REGNUM 10
  264.  
  265. /* Register in which address to store a structure value is passed to
  266.    a function.  */
  267.  
  268. #define STRUCT_VALUE_REGNUM 1
  269.  
  270. /* Define the classes of registers for register constraints in the
  271.    machine description.  Also define ranges of constants.
  272.  
  273.    One of the classes must always be named ALL_REGS and include all hard regs.
  274.    If there is more than one class, another class must be named NO_REGS
  275.    and contain no registers.
  276.  
  277.    The name GENERAL_REGS must be the name of a class (or an alias for
  278.    another name such as ALL_REGS).  This is the class of registers
  279.    that is allowed by "g" or "r" in a register constraint.
  280.    Also, registers outside this class are allocated only when
  281.    instructions express preferences for them.
  282.  
  283.    The classes must be numbered in nondecreasing order; that is,
  284.    a larger-numbered class must never be contained completely
  285.    in a smaller-numbered class.
  286.  
  287.    For any two classes, it is very desirable that there be another
  288.    class that represents their union.  */
  289.  
  290. enum reg_class
  291.   {
  292.     NO_REGS, ADDR_REGS, DATA_REGS,
  293.     FP_REGS, ALL_REGS, LIM_REG_CLASSES
  294.   };
  295.  
  296. #define GENERAL_REGS DATA_REGS
  297. #define N_REG_CLASSES (int) LIM_REG_CLASSES
  298.  
  299. /* Give names of register classes as strings for dump file.  */
  300.  
  301. #define REG_CLASS_NAMES                         \
  302. { "NO_REGS", "ADDR_REGS", "DATA_REGS", "FP_REGS", "ALL_REGS" }
  303.  
  304. /* Define which registers fit in which classes.  This is an initializer for
  305.    a vector of HARD_REG_SET of length N_REG_CLASSES.  */
  306.  
  307. #define REG_CLASS_CONTENTS {0, 0x0fffe, 0x0ffff, 0xf0000, 0xfffff}
  308.  
  309. /* The same information, inverted:
  310.    Return the class number of the smallest class containing
  311.    reg number REGNO.  This could be a conditional expression
  312.    or could index an array.  */
  313.  
  314. #define REGNO_REG_CLASS(REGNO)                         \
  315.   ((REGNO) >= 16 ? FP_REGS : (REGNO) != 0 ? ADDR_REGS : DATA_REGS)
  316.  
  317. /* The class value for index registers, and the one for base regs.  */
  318.  
  319. #define INDEX_REG_CLASS ADDR_REGS
  320. #define BASE_REG_CLASS ADDR_REGS
  321.  
  322. /* Get reg_class from a letter such as appears in the machine description.  */
  323.  
  324. #define REG_CLASS_FROM_LETTER(C)                    \
  325.   ((C) == 'a' ? ADDR_REGS :                        \
  326.   ((C) == 'd' ? DATA_REGS :                        \
  327.   ((C) == 'f' ? FP_REGS   : NO_REGS)))
  328.  
  329. /* The letters I, J, K, L and M in a register constraint string can be used
  330.    to stand for particular ranges of immediate operands.
  331.    This macro defines what the ranges are.
  332.    C is the letter, and VALUE is a constant value.
  333.    Return 1 if VALUE is in the range specified by C.  */
  334.  
  335. #define CONST_OK_FOR_LETTER_P(VALUE, C)                    \
  336.   ((C) == 'I' ? (unsigned) (VALUE) < 256 :                \
  337.    (C) == 'J' ? (unsigned) (VALUE) < 4096 :                \
  338.    (C) == 'K' ? (VALUE) >= -32768 && (VALUE) < 32768 : 0)
  339.  
  340. /* Similar, but for floating constants, and defining letters G and H.
  341.    Here VALUE is the CONST_DOUBLE rtx itself.  */
  342.  
  343. #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)  1
  344.  
  345. /* Given an rtx X being reloaded into a reg required to be in class CLASS,
  346.    return the class of reg to actually use.  In general this is just CLASS;
  347.    but on some machines in some cases it is preferable to use a more
  348.    restrictive class.  */
  349.  
  350. #define PREFERRED_RELOAD_CLASS(X, CLASS)                \
  351.     (GET_CODE(X) == CONST_DOUBLE ? FP_REGS :                \
  352.      GET_CODE(X) == CONST_INT ? DATA_REGS :                \
  353.      GET_CODE(X) == LABEL_REF ||                    \
  354.      GET_CODE(X) == SYMBOL_REF ||                    \
  355.      GET_CODE(X) == CONST ? ADDR_REGS : (CLASS))
  356.  
  357. /* Return the maximum number of consecutive registers needed to represent
  358.    mode MODE in a register of class CLASS.  */
  359.  
  360. #define CLASS_MAX_NREGS(CLASS, MODE)                    \
  361.   ((CLASS) == FP_REGS ? 1 :                        \
  362.    (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  363.  
  364. /* Stack layout; function entry, exit and calling.  */
  365.  
  366. /* Define this if pushing a word on the stack makes the stack pointer a
  367.    smaller address.  */
  368.  
  369. /* #define STACK_GROWS_DOWNWARD */
  370.  
  371. /* Define this if the nominal address of the stack frame is at the
  372.    high-address end of the local variables; that is, each additional local
  373.    variable allocated goes at a more negative offset in the frame.  */
  374.  
  375. /* #define FRAME_GROWS_DOWNWARD */
  376.  
  377. /* Offset within stack frame to start allocating local variables at.
  378.    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
  379.    first local allocated.  Otherwise, it is the offset to the BEGINNING
  380.    of the first local allocated.  */
  381.  
  382. #define STARTING_FRAME_OFFSET                          \
  383.      (STACK_POINTER_OFFSET + current_function_outgoing_args_size)
  384.  
  385. #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = STARTING_FRAME_OFFSET
  386.  
  387. /* If we generate an insn to push BYTES bytes, this says how many the stack
  388.    pointer really advances by.  On the 370, we have no push instruction.  */
  389.  
  390. /* #define PUSH_ROUNDING(BYTES) */
  391.  
  392. /* Accumulate the outgoing argument count so we can request the right
  393.    DSA size and determine stack offset.  */
  394.  
  395. #define ACCUMULATE_OUTGOING_ARGS
  396.  
  397. /* Define offset from stack pointer, to location where a parm can be
  398.    pushed.  */
  399.  
  400. #define STACK_POINTER_OFFSET 148
  401.  
  402. /* Offset of first parameter from the argument pointer register value.  */
  403.  
  404. #define FIRST_PARM_OFFSET(FNDECL) 0
  405.  
  406. /* 1 if N is a possible register number for function argument passing.
  407.    On the 370, no registers are used in this way.  */
  408.  
  409. #define FUNCTION_ARG_REGNO_P(N) 0
  410.  
  411. /* Define a data type for recording info about an argument list during
  412.    the scan of that argument list.  This data type should hold all
  413.    necessary information about the function itself and about the args
  414.    processed so far, enough to enable macros such as FUNCTION_ARG to
  415.    determine where the next arg should go.  */
  416.  
  417. #define CUMULATIVE_ARGS int
  418.  
  419. /* Initialize a variable CUM of type CUMULATIVE_ARGS for a call to
  420.    a function whose data type is FNTYPE.
  421.    For a library call, FNTYPE is 0.  */
  422.  
  423. #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME)  ((CUM) = 0)
  424.  
  425. /* Update the data in CUM to advance over an argument of mode MODE and
  426.    data type TYPE.  (TYPE is null for libcalls where that information
  427.    may not be available.) */
  428.  
  429. #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)            \
  430.  ((CUM) += ((MODE) == DFmode || (MODE) == SFmode            \
  431.         ? 256                            \
  432.         : (MODE) != BLKmode                             \
  433.         ? (GET_MODE_SIZE (MODE) + 3) / 4                 \
  434.         : (int_size_in_bytes (TYPE) + 3) / 4))
  435.  
  436. /* Define where to put the arguments to a function.  Value is zero to push
  437.    the argument on the stack, or a hard register in which to store the
  438.    argument.  */
  439.  
  440. #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0
  441.  
  442. /* For an arg passed partly in registers and partly in memory, this is the
  443.    number of registers used.  For args passed entirely in registers or
  444.    entirely in memory, zero.  */
  445.  
  446. #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
  447.  
  448. /* Define if returning from a function call automatically pops the
  449.    arguments described by the number-of-args field in the call.  */
  450.  
  451. #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
  452.  
  453. /* Define how to find the value returned by a function.  VALTYPE is the
  454.    data type of the value (as a tree).
  455.    If the precise function being called is known, FUNC is its FUNCTION_DECL;
  456.    otherwise, FUNC is 15.  */
  457.  
  458. #define RET_REG(MODE)    ((MODE) == DFmode || (MODE) == SFmode ? 16 : 15)
  459.  
  460. /* On the 370 the return value is in R15 or R16.  */
  461.  
  462. #define FUNCTION_VALUE(VALTYPE, FUNC)                      \
  463.   gen_rtx(REG, TYPE_MODE (VALTYPE), RET_REG(TYPE_MODE(VALTYPE)))
  464.  
  465. /* Define how to find the value returned by a library function assuming
  466.    the value has mode MODE.  */
  467.  
  468. #define LIBCALL_VALUE(MODE)  gen_rtx(REG, MODE, RET_REG(MODE))
  469.  
  470. /* 1 if N is a possible register number for a function value.
  471.    On the 370 under C/370, R15 and R16 are thus used.  */
  472.  
  473. #define FUNCTION_VALUE_REGNO_P(N) ((N) == 15 || (N) == 16)
  474.  
  475. /* This macro definition sets up a default value for `main' to return.  */
  476.  
  477. #define DEFAULT_MAIN_RETURN  c_expand_return (integer_zero_node)
  478.  
  479. /* This macro generates the assembly code for function entry.
  480.    All of the C/370 environment is preserved.  */
  481.  
  482. #define FUNCTION_PROLOGUE(FILE, LSIZE)                    \
  483. {                                     \
  484.   static int function_label_index = 1;                    \
  485.   static int function_first = 0;                    \
  486.   static int function_year, function_month, function_day;        \
  487.   static int function_hour, function_minute, function_second;        \
  488.   int i;                                \
  489.   if (!function_first)                            \
  490.     {                                    \
  491.       struct tm *function_time;                        \
  492.       time_t lcltime;                            \
  493.       time (&lcltime);                            \
  494.       function_time = localtime (&lcltime);                \
  495.       function_year = function_time->tm_year + 1900;            \
  496.       function_month = function_time->tm_mon + 1;            \
  497.       function_day = function_time->tm_mday;                \
  498.       function_hour = function_time->tm_hour;                \
  499.       function_minute = function_time->tm_min;                \
  500.       function_second = function_time->tm_sec;                \
  501.     }                                    \
  502.   fprintf (FILE, "\tUSING\t*,15\n");                    \
  503.   fprintf (FILE, "\tB\tFPL%03d\n", function_label_index);        \
  504.   fprintf (FILE, "\tDC\tAL1(FPL%03d+4-*)\n", function_label_index + 1);    \
  505.   fprintf (FILE, "\tDC\tX'CE',X'A0',X'10'\n");                \
  506.   fprintf (FILE, "\tDC\tA($PPA2)\n");                    \
  507.   fprintf (FILE, "\tDC\tF'%d'\n", 0);                    \
  508.   fprintf (FILE, "\tDC\tF'%d'\n", STACK_POINTER_OFFSET + LSIZE        \
  509.             + current_function_outgoing_args_size);        \
  510.   fprintf (FILE, "FPL%03d\tEQU\t*\n", function_label_index + 1);    \
  511.   fprintf (FILE, "\tDC\tAL2(%d),C'%s'\n", strlen (mvs_function_name),    \
  512.     mvs_function_name);                        \
  513.   fprintf (FILE, "\tDS\t0F\n");                        \
  514.   if (!function_first)                            \
  515.     {                                    \
  516.       fprintf (FILE, "$PPA2\tEQU\t*\n");                \
  517.       fprintf (FILE, "\tDC\tX'03',X'00',X'33',X'00'\n");        \
  518.       fprintf (FILE, "\tDC\tV(CEESTART),A(0)\n");            \
  519.       fprintf (FILE, "\tDC\tA($TIMES)\n");                \
  520.       fprintf (FILE, "\tDS\t0F\n");                    \
  521.       fprintf (FILE, "$TIMES\tEQU\t*\n");                \
  522.       fprintf (FILE, "\tDC\tCL4'%d',CL4'%02d%02d',CL6'%02d%02d00'\n",    \
  523.               function_year, function_month, function_day,    \
  524.               function_hour, function_minute, function_second);    \
  525.       fprintf (FILE, "\tDC\tCL2'01',CL4'0100'\n");            \
  526.     }                                    \
  527.   fprintf (FILE, "\tDS\t0H\n");                        \
  528.   fprintf (FILE, "FPL%03d\tEQU\t*\n", function_label_index);        \
  529.   fprintf (FILE, "\tSTM\t14,12,12(13)\n");                \
  530.   fprintf (FILE, "\tL\t2,76(,13)\n");                    \
  531.   fprintf (FILE, "\tL\t0,16(,15)\n");                    \
  532.   fprintf (FILE, "\tALR\t0,2\n");                    \
  533.   fprintf (FILE, "\tCL\t0,12(,12)\n");                    \
  534.   fprintf (FILE, "\tBNH\t*+10\n");                    \
  535.   fprintf (FILE, "\tL\t15,116(,12)\n");                    \
  536.   fprintf (FILE, "\tBALR\t14,15\n");                    \
  537.   fprintf (FILE, "\tL\t15,72(,13)\n");                    \
  538.   fprintf (FILE, "\tSTM\t15,0,72(2)\n");                \
  539.   fprintf (FILE, "\tMVI\t0(2),X'10'\n");                \
  540.   fprintf (FILE, "\tST\t13,4(,2)\n ");                    \
  541.   fprintf (FILE, "\tLR\t13,2\n");                    \
  542.   fprintf (FILE, "\tLR\t11,1\n");                    \
  543.   fprintf (FILE, "\tDROP\t15\n");                    \
  544.   fprintf (FILE, "\tBALR\t%d,0\n", BASE_REGISTER);            \
  545.   fprintf (FILE, "PG%d\tEQU\t*\n", mvs_page_num );            \
  546.   fprintf (FILE, "\tUSING\t*,%d\n", BASE_REGISTER);            \
  547.   fprintf (FILE, "\tL\t%d,=A(PGT%d)\n", PAGE_REGISTER, mvs_page_num);    \
  548.   mvs_page_code = 4;                            \
  549.   mvs_page_lit = 4;                            \
  550.   mvs_check_page (FILE, 0, 0);                        \
  551.   function_base_page = mvs_page_num;                    \
  552.   function_first = 1;                            \
  553.   function_label_index += 2;                        \
  554. }
  555.  
  556. #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)            \
  557. {                                    \
  558.   if (strlen (NAME) * 2 > mvs_function_name_length)            \
  559.     {                                    \
  560.       if (mvs_function_name)                        \
  561.     free (mvs_function_name);                    \
  562.       mvs_function_name = 0;                        \
  563.     }                                    \
  564.   if (!mvs_function_name)                        \
  565.     {                                    \
  566.       mvs_function_name_length = strlen (NAME) * 2;            \
  567.       mvs_function_name = (char *) malloc (mvs_function_name_length);    \
  568.       if (mvs_function_name == 0)                    \
  569.     {                                \
  570.       fatal ("virtual memory exceeded");                \
  571.       abort ();                            \
  572.     }                                \
  573.     }                                    \
  574.   if (!strcmp (NAME, "main"))                        \
  575.     strcpy (mvs_function_name, "gccmain");                \
  576.   else                                    \
  577.     strcpy (mvs_function_name, NAME);                    \
  578.   fprintf (FILE, "\tDS\t0H\n");                        \
  579.   assemble_name (FILE, mvs_function_name);                \
  580.   fputs ("\tCSECT\n", FILE);                        \
  581. }
  582.  
  583. /* This macro generates the assembly code for function exit, on machines
  584.    that need it.  If FUNCTION_EPILOGUE is not defined then individual
  585.    return instructions are generated for each return statement.  Args are
  586.    same as for FUNCTION_PROLOGUE.
  587.  
  588.    The function epilogue should not depend on the current stack pointer!
  589.    It should use the frame pointer only.  This is mandatory because
  590.    of alloca; we also take advantage of it to omit stack adjustments
  591.    before returning.  */
  592.  
  593. #define FUNCTION_EPILOGUE(FILE, LSIZE)                    \
  594. {                                    \
  595.   int i;                                \
  596.   check_label_emit();                            \
  597.   mvs_check_page (FILE,14,0);                        \
  598.   fprintf (FILE, "\tL\t13,4(,13)\n");                    \
  599.   fprintf (FILE, "\tL\t14,12(,13)\n");                    \
  600.   fprintf (FILE, "\tLM\t2,12,28(13)\n");                \
  601.   fprintf (FILE, "\tBALR\t1,14\n");                    \
  602.   fprintf (FILE, "\tDC\tA(");                        \
  603.   mvs_page_num++;                            \
  604.   assemble_name (FILE, mvs_function_name);                \
  605.   fprintf (FILE, ")\n" );                        \
  606.   fprintf (FILE, "\tDS\t0F\n" );                    \
  607.   fprintf (FILE, "\tLTORG\n");                        \
  608.   fprintf (FILE, "\tDS\t0F\n");                        \
  609.   fprintf (FILE, "PGT%d\tEQU\t*\n", function_base_page);        \
  610.   mvs_free_label();                            \
  611.   for ( i = function_base_page; i < mvs_page_num; i++ )            \
  612.     fprintf (FILE, "\tDC\tA(PG%d)\n", i);                \
  613. }
  614.  
  615. /* Output assembler code for a block containing the constant parts of a
  616.    trampoline, leaving space for the variable parts.
  617.  
  618.    On the 370, the trampoline contains these instructions:
  619.  
  620.         BALR  14,0
  621.         USING *,14
  622.         L     STATIC_CHAIN_REGISTER,X
  623.         L     15,Y
  624.         BR    15
  625.    X    DS    0F
  626.    Y    DS    0F  */
  627.  
  628. #define TRAMPOLINE_TEMPLATE(FILE)                    \
  629. {                                    \
  630.   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x05E0));    \
  631.   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x5800 |     \
  632.                STATIC_CHAIN_REGNUM << 4));            \
  633.   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0xE00A));    \
  634.   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x58F0));     \
  635.   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0xE00E));    \
  636.   ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x07FF));    \
  637.   ASM_OUTPUT_SHORT (FILE, const0_rtx);                    \
  638.   ASM_OUTPUT_SHORT (FILE, const0_rtx);                    \
  639.   ASM_OUTPUT_SHORT (FILE, const0_rtx);                    \
  640.   ASM_OUTPUT_SHORT (FILE, const0_rtx);                    \
  641. }
  642.  
  643. /* Length in units of the trampoline for entering a nested function.  */
  644.  
  645. #define TRAMPOLINE_SIZE 20
  646.  
  647. /* Emit RTL insns to initialize the variable parts of a trampoline.  */
  648.  
  649. #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)            \
  650. {                                    \
  651.   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 12)), CXT); \
  652.   emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 16)), FNADDR); \
  653. }
  654.  
  655. /* Output assembler code to FILE to increment profiler label # LABELNO
  656.    for profiling a function entry.  */
  657.  
  658. #define FUNCTION_PROFILER(FILE, LABELNO)                 \
  659.   fprintf (FILE, "Error: No profiling available.\n")
  660.  
  661. /* Define EXIT_IGNORE_STACK if, when returning from a function, the stack
  662.    pointer does not matter (provided there is a frame pointer).  */
  663.  
  664. #define EXIT_IGNORE_STACK    1
  665.  
  666. /* Addressing modes, and classification of registers for them.  */
  667.  
  668. /* #define HAVE_POST_INCREMENT */
  669. /* #define HAVE_POST_DECREMENT */
  670.  
  671. /* #define HAVE_PRE_DECREMENT */
  672. /* #define HAVE_PRE_INCREMENT */
  673.  
  674. /* These assume that REGNO is a hard or pseudo reg number.  They give
  675.    nonzero only if REGNO is a hard reg of the suitable class or a pseudo
  676.    reg currently allocated to a suitable hard reg.
  677.    These definitions are NOT overridden anywhere.  */
  678.  
  679. #define REGNO_OK_FOR_INDEX_P(REGNO)                     \
  680.   (((REGNO) > 0 && (REGNO) < 16)                    \
  681.     || (reg_renumber[REGNO] > 0 && reg_renumber[REGNO] < 16))
  682.  
  683. #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P(REGNO)
  684.  
  685. #define REGNO_OK_FOR_DATA_P(REGNO)                     \
  686.   ((REGNO) < 16 || (unsigned) reg_renumber[REGNO] < 16)
  687.  
  688. #define REGNO_OK_FOR_FP_P(REGNO)                     \
  689.   ((unsigned) ((REGNO) - 16) < 4 || (unsigned) (reg_renumber[REGNO] - 16) < 4)
  690.  
  691. /* Now macros that check whether X is a register and also,
  692.    strictly, whether it is in a specified class.  */
  693.  
  694. /* 1 if X is a data register.  */
  695.  
  696. #define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X)))
  697.  
  698. /* 1 if X is an fp register.  */
  699.  
  700. #define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
  701.  
  702. /* 1 if X is an address register.  */
  703.  
  704. #define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X)))
  705.  
  706. /* Maximum number of registers that can appear in a valid memory address.  */
  707.  
  708. #define MAX_REGS_PER_ADDRESS 2
  709.  
  710. /* Recognize any constant value that is a valid address.  */
  711.  
  712. #define CONSTANT_ADDRESS_P(X)                        \
  713.   (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF        \
  714.   || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST_DOUBLE        \
  715.   || (GET_CODE (X) == CONST                        \
  716.       && GET_CODE (XEXP (XEXP (X, 0), 0)) == LABEL_REF)        \
  717.   || (GET_CODE (X) == CONST                        \
  718.       && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF        \
  719.       && !SYMBOL_REF_FLAG (XEXP (XEXP (X, 0), 0))))
  720.  
  721. /* Nonzero if the constant value X is a legitimate general operand.
  722.    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
  723.  
  724. #define LEGITIMATE_CONSTANT_P(X) 1
  725.  
  726. /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check
  727.    its validity for a certain class.  We have two alternate definitions
  728.    for each of them.  The usual definition accepts all pseudo regs; the
  729.    other rejects them all.  The symbol REG_OK_STRICT causes the latter
  730.    definition to be used.
  731.  
  732.    Most source files want to accept pseudo regs in the hope that they will
  733.    get allocated to the class that the insn wants them to be in.
  734.    Some source files that are used after register allocation
  735.    need to be strict.  */
  736.  
  737. #ifndef REG_OK_STRICT
  738.  
  739. /* Nonzero if X is a hard reg that can be used as an index or if it is
  740.   a pseudo reg.  */
  741.  
  742. #define REG_OK_FOR_INDEX_P(X)                        \
  743.   ((REGNO(X) > 0 && REGNO(X) < 16) || REGNO(X) >= 20)
  744.  
  745. /* Nonzero if X is a hard reg that can be used as a base reg or if it is
  746.    a pseudo reg.  */
  747.  
  748. #define REG_OK_FOR_BASE_P(X)    REG_OK_FOR_INDEX_P(X)
  749.  
  750. #else /* REG_OK_STRICT */
  751.  
  752. /* Nonzero if X is a hard reg that can be used as an index.  */
  753.  
  754. #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P(REGNO(X))
  755.  
  756. /* Nonzero if X is a hard reg that can be used as a base reg.  */
  757.  
  758. #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P(REGNO(X))
  759.  
  760. #endif /* REG_OK_STRICT */
  761.  
  762. /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a
  763.    valid memory address for an instruction.
  764.    The MODE argument is the machine mode for the MEM expression
  765.    that wants to use this address.
  766.  
  767.    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
  768.    except for CONSTANT_ADDRESS_P which is actually machine-independent.  */
  769.  
  770. #define COUNT_REGS(X, REGS, FAIL)                    \
  771.  if (REG_P (X) && REG_OK_FOR_BASE_P (X))                \
  772.    REGS += 1;                                \
  773.  else if (GET_CODE (X) != CONST_INT || (unsigned) INTVAL (X) >= 4096)    \
  774.    goto FAIL;
  775.  
  776. #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)                \
  777. {                                    \
  778.   if (REG_P (X) && REG_OK_FOR_BASE_P (X))                \
  779.     goto ADDR;                                \
  780.   if (GET_CODE (X) == PLUS)                        \
  781.     {                                    \
  782.       int regs = 0;                            \
  783.       rtx x0 = XEXP (X, 0);                        \
  784.       rtx x1 = XEXP (X, 1);                        \
  785.       if (GET_CODE (x0) == PLUS)                    \
  786.     {                                \
  787.       COUNT_REGS (XEXP (x0, 0), regs, FAIL);            \
  788.       COUNT_REGS (XEXP (x0, 1), regs, FAIL);            \
  789.       COUNT_REGS (x1, regs, FAIL);                    \
  790.       if (regs == 2)                        \
  791.         goto ADDR;                            \
  792.     }                                \
  793.       else if (GET_CODE (x1) == PLUS)                    \
  794.     {                                \
  795.       COUNT_REGS (x0, regs, FAIL);                    \
  796.       COUNT_REGS (XEXP (x1, 0), regs, FAIL);            \
  797.       COUNT_REGS (XEXP (x1, 1), regs, FAIL);            \
  798.       if (regs == 2)                        \
  799.         goto ADDR;                            \
  800.     }                                \
  801.       else                                \
  802.     {                                \
  803.       COUNT_REGS (x0, regs, FAIL);                    \
  804.       COUNT_REGS (x1, regs, FAIL);                    \
  805.       if (regs != 0)                        \
  806.         goto ADDR;                            \
  807.     }                                \
  808.     }                                    \
  809.   FAIL: ;                                \
  810. }
  811.  
  812. /* The 370 has no mode dependent addresses.  */
  813.  
  814. #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
  815.  
  816. /* Try machine-dependent ways of modifying an illegitimate address
  817.    to be legitimate.  If we find one, return the new, valid address.
  818.    This macro is used in only one place: `memory_address' in explow.c.  */
  819.  
  820. #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)                \
  821. {                                    \
  822.   if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1)))        \
  823.     (X) = gen_rtx (PLUS, SImode, XEXP (X, 0),                \
  824.            copy_to_mode_reg (SImode, XEXP (X, 1)));        \
  825.   if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0)))        \
  826.     (X) = gen_rtx (PLUS, SImode, XEXP (X, 1),                \
  827.            copy_to_mode_reg (SImode, XEXP (X, 0)));        \
  828.   if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT)        \
  829.     (X) = gen_rtx (PLUS, SImode, XEXP (X, 1),                \
  830.            force_operand (XEXP (X, 0), 0));            \
  831.   if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT)        \
  832.     (X) = gen_rtx (PLUS, SImode, XEXP (X, 0),                \
  833.            force_operand (XEXP (X, 1), 0));            \
  834.   if (memory_address_p (MODE, X))                    \
  835.     goto WIN;                                \
  836. }
  837.  
  838. /* Specify the machine mode that this machine uses for the index in the
  839.    tablejump instruction.  */
  840.  
  841. #define CASE_VECTOR_MODE SImode
  842.  
  843. /* Define this if the tablejump instruction expects the table to contain
  844.    offsets from the address of the table.
  845.    Do not define this if the table should contain absolute addresses.  */
  846.  
  847. /* #define CASE_VECTOR_PC_RELATIVE */
  848.  
  849. /* Specify the tree operation to be used to convert reals to integers.  */
  850.  
  851. #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
  852.  
  853. /* Define this if fixuns_trunc is the same as fix_trunc.  */
  854.  
  855. #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
  856.  
  857. /* We use "unsigned char" as default.  */
  858.  
  859. #define DEFAULT_SIGNED_CHAR 0
  860.  
  861. /* This is the kind of divide that is easiest to do in the general case.  */
  862.  
  863. #define EASY_DIV_EXPR TRUNC_DIV_EXPR
  864.  
  865. /* Max number of bytes we can move from memory to memory in one reasonably
  866.    fast instruction.  */
  867.  
  868. #define MOVE_MAX 256
  869.  
  870. /* Define this if zero-extension is slow (more than one real instruction).  */
  871.  
  872. #define SLOW_ZERO_EXTEND
  873.  
  874. /* Nonzero if access to memory by bytes is slow and undesirable.  */
  875.  
  876. #define SLOW_BYTE_ACCESS 1
  877.  
  878. /* Define if shifts truncate the shift count which implies one can omit
  879.    a sign-extension or zero-extension of a shift count.  */
  880.  
  881. /* #define SHIFT_COUNT_TRUNCATED */
  882.  
  883. /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
  884.    is done just by pretending it is already truncated.  */
  885.  
  886. #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC)    (OUTPREC != 16)
  887.  
  888. /* We assume that the store-condition-codes instructions store 0 for false
  889.    and some other value for true.  This is the value stored for true.  */
  890.  
  891. /* #define STORE_FLAG_VALUE -1 */
  892.  
  893. /* When a prototype says `char' or `short', really pass an `int'.  */
  894.  
  895. #define PROMOTE_PROTOTYPES
  896.  
  897. /* Don't perform CSE on function addresses.  */
  898.  
  899. #define NO_FUNCTION_CSE
  900.  
  901. /* Specify the machine mode that pointers have.
  902.    After generation of rtl, the compiler makes no further distinction
  903.    between pointers and any other objects of this machine mode.  */
  904.  
  905. #define Pmode SImode
  906.  
  907. /* A function address in a call instruction is a byte address (for
  908.    indexing purposes) so give the MEM rtx a byte's mode.  */
  909.  
  910. #define FUNCTION_MODE QImode
  911.  
  912. /* Compute the cost of computing a constant rtl expression RTX whose
  913.    rtx-code is CODE.  The body of this macro is a portion of a switch
  914.    statement.  If the code is computed here, return it with a return
  915.    statement.  Otherwise, break from the switch.  */
  916.  
  917. #define CONST_COSTS(RTX, CODE, OUTERCODE)                \
  918.   case CONST_INT:                            \
  919.     if ((unsigned) INTVAL (RTX) < 0xfff) return 1;            \
  920.   case CONST:                                \
  921.   case LABEL_REF:                            \
  922.   case SYMBOL_REF:                            \
  923.     return 2;                                \
  924.   case CONST_DOUBLE:                            \
  925.     return 4;
  926.  
  927. /* Tell final.c how to eliminate redundant test instructions.  */
  928.  
  929. /* Here we define machine-dependent flags and fields in cc_status
  930.    (see `conditions.h').  */
  931.  
  932. /* Store in cc_status the expressions that the condition codes will
  933.    describe after execution of an instruction whose pattern is EXP.
  934.    Do not alter them if the instruction would not alter the cc's.
  935.  
  936.    On the 370, load insns do not alter the cc's.  However, in some
  937.    cases these instructions can make it possibly invalid to use the
  938.    saved cc's.  In those cases we clear out some or all of the saved
  939.    cc's so they won't be used.  */
  940.  
  941. #define NOTICE_UPDATE_CC(EXP, INSN)                    \
  942. {                                    \
  943.   rtx exp = (EXP);                            \
  944.   if (GET_CODE (exp) == PARALLEL) /* Check this */            \
  945.     exp = XVECEXP (exp, 0, 0);                        \
  946.   if (GET_CODE (exp) != SET)                        \
  947.     CC_STATUS_INIT;                            \
  948.   else                                    \
  949.     {                                    \
  950.       if (XEXP (exp, 0) == cc0_rtx)                    \
  951.     {                                \
  952.       cc_status.value1 = XEXP (exp, 0);                \
  953.       cc_status.value2 = XEXP (exp, 1);                \
  954.       cc_status.flags = 0;                        \
  955.     }                                \
  956.       else                                \
  957.     {                                \
  958.       if (cc_status.value1                        \
  959.           && reg_mentioned_p (XEXP (exp, 0), cc_status.value1))    \
  960.         cc_status.value1 = 0;                    \
  961.       if (cc_status.value2                        \
  962.           && reg_mentioned_p (XEXP (exp, 0), cc_status.value2))    \
  963.         cc_status.value2 = 0;                    \
  964.       switch (GET_CODE (XEXP (exp, 1)))                \
  965.         {                                \
  966.           case PLUS:     case MINUS: case MULT:   /* case UMULT: */    \
  967.           case DIV:      case UDIV:  case NEG:    case ASHIFT:    \
  968.           case ASHIFTRT: case AND:   case IOR:    case XOR:        \
  969.           case ABS:      case NOT:                    \
  970.         CC_STATUS_SET (XEXP (exp, 0), XEXP (exp, 1));        \
  971.         }                                \
  972.     }                                \
  973.     }                                    \
  974. }
  975.  
  976.  
  977. #define CC_STATUS_SET(V1, V2)                        \
  978. {                                    \
  979.   cc_status.flags = 0;                            \
  980.   cc_status.value1 = (V1);                        \
  981.   cc_status.value2 = (V2);                        \
  982.   if (cc_status.value1                            \
  983.       && reg_mentioned_p (cc_status.value1, cc_status.value2))        \
  984.     cc_status.value2 = 0;                        \
  985. }
  986.  
  987. #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV)                 \
  988. { if (cc_status.flags & CC_NO_OVERFLOW)    return NO_OV; return NORMAL; }
  989.  
  990. /* Control the assembler format that we output.  */
  991.  
  992. #define TEXT_SECTION_ASM_OP "* Program text area"
  993. #define DATA_SECTION_ASM_OP "* Program data area"
  994. #define INIT_SECTION_ASM_OP "* Program initialization area"
  995. #define CTOR_LIST_BEGIN        /* NO OP */
  996. #define CTOR_LIST_END        /* NO OP */
  997.  
  998. /* How to refer to registers in assembler output.  This sequence is
  999.    indexed by compiler's hard-register-number (see above).  */
  1000.  
  1001. #define REGISTER_NAMES                            \
  1002. { "0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",            \
  1003.   "8",  "9", "10", "11", "12", "13", "14", "15",            \
  1004.   "0",  "2",  "4",  "6"                            \
  1005. }
  1006.  
  1007. /* How to renumber registers for dbx and gdb.  */
  1008.  
  1009. #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
  1010.  
  1011. #define ASM_FILE_START(FILE) fputs ("\tCSECT\n", FILE);
  1012. #define ASM_FILE_END(FILE) fputs ("\tEND\n", FILE);
  1013. #define ASM_IDENTIFY_GCC(FILE)
  1014. #define ASM_COMMENT_START "*"
  1015. #define ASM_APP_OFF ""
  1016. #define ASM_APP_ON ""
  1017.  
  1018. #define ASM_OUTPUT_LABEL(FILE, NAME)                     \
  1019. { assemble_name (FILE, NAME); fputs ("\tEQU\t*\n", FILE); }
  1020.  
  1021. #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)    /* NO OP */
  1022.  
  1023. #define ASM_GLOBALIZE_LABEL(FILE, NAME)                    \
  1024. { fputs ("\tENTRY\t", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE); }
  1025.  
  1026. /* MVS externals are limited to 8 characters, upper case only.
  1027.    The '_' is mapped to '@', except for MVS functions, then '#'.  */
  1028.  
  1029. #define MAX_MVS_LABEL_SIZE 8
  1030.  
  1031. #define ASM_OUTPUT_LABELREF(FILE, NAME)                    \
  1032. {                                    \
  1033.   char *bp, ch, temp[MAX_MVS_LABEL_SIZE + 1];                \
  1034.   if (strlen (NAME) > MAX_MVS_LABEL_SIZE)                \
  1035.     {                                    \
  1036.       strncpy (temp, NAME, MAX_MVS_LABEL_SIZE);                \
  1037.       temp[MAX_MVS_LABEL_SIZE] = '\0';                    \
  1038.     }                                    \
  1039.   else                                    \
  1040.     strcpy (temp,NAME);                            \
  1041.   if (!strcmp (temp,"main"))                        \
  1042.     strcpy (temp,"gccmain");                        \
  1043.   if (mvs_function_check (temp))                    \
  1044.     ch = '#';                                \
  1045.   else                                    \
  1046.     ch = '@';                                \
  1047.   for (bp = temp; *bp; bp++)                        \
  1048.     {                                    \
  1049.       if (islower (*bp)) *bp = toupper (*bp);                \
  1050.       if (*bp == '_') *bp = ch;                        \
  1051.     }                                    \
  1052.   fprintf (FILE, "%s", temp);                        \
  1053. }
  1054.  
  1055. #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)            \
  1056.   sprintf (LABEL, "*%s%d", PREFIX, NUM)
  1057.  
  1058. /* Generate internal label.  Since we can branch here from off page, we
  1059.    must reload the base register.  */
  1060.  
  1061. #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM)             \
  1062. {                                    \
  1063.   if (!strcmp (PREFIX,"L"))                        \
  1064.     {                                    \
  1065.       mvs_add_label(NUM);                        \
  1066.       mvs_label_emited = 1;                        \
  1067.     }                                    \
  1068.   fprintf (FILE, "%s%d\tEQU\t*\n", PREFIX, NUM);            \
  1069. }
  1070.  
  1071. /* Generate case label.  */
  1072.  
  1073. #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, TABLE)            \
  1074.    fprintf (FILE, "%s%d\tEQU\t*\n", PREFIX, NUM)
  1075.  
  1076. /* This is how to output an element of a case-vector that is absolute.  */
  1077.  
  1078. #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)                  \
  1079.   mvs_check_page (FILE, 4, 0);                        \
  1080.   fprintf (FILE, "\tDC\tA(L%d)\n", VALUE)
  1081.  
  1082. /* This is how to output an element of a case-vector that is relative.  */
  1083.  
  1084. #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL)             \
  1085.   mvs_check_page (FILE, 4, 0);                        \
  1086.   fprintf (FILE, "\tDC\tA(L%d-L%d)\n", VALUE, REL)
  1087.  
  1088. /* This is how to output an insn to push a register on the stack.
  1089.    It need not be very fast code.  */
  1090.  
  1091. #define ASM_OUTPUT_REG_PUSH(FILE, REGNO)                \
  1092.   mvs_check_page (FILE, 8, 4);                        \
  1093.   fprintf (FILE, "\tS\t13,=F'4'\n\tST\t%s,%d(13)\n",            \
  1094.      reg_names[REGNO], STACK_POINTER_OFFSET)
  1095.  
  1096. /* This is how to output an insn to pop a register from the stack.
  1097.    It need not be very fast code.  */
  1098.  
  1099. #define ASM_OUTPUT_REG_POP(FILE, REGNO)                    \
  1100.   mvs_check_page (FILE, 8, 0);                        \
  1101.   fprintf (FILE, "\tL\t%s,%d(13)\n\tLA\t13,4(13)\n",            \
  1102.      reg_names[REGNO], STACK_POINTER_OFFSET)
  1103.  
  1104. /* This is how to output an assembler line defining a `double' constant.  */
  1105.  
  1106. #define ASM_OUTPUT_DOUBLE(FILE, VALUE)                    \
  1107.   fprintf (FILE, "\tDC\tD'%.18G'\n", (VALUE))
  1108.  
  1109. /* This is how to output an assembler line defining a `float' constant.  */
  1110.  
  1111. #define ASM_OUTPUT_FLOAT(FILE, VALUE)                    \
  1112.   fprintf (FILE, "\tDC\tE'%.9G'\n", (VALUE))
  1113.  
  1114. /* This outputs an integer, if not a CONST_INT must be address constant.  */
  1115.  
  1116. #define ASM_OUTPUT_INT(FILE, EXP)                    \
  1117. {                                     \
  1118.   if (GET_CODE (EXP) == CONST_INT)                    \
  1119.     {                                    \
  1120.       fprintf (FILE, "\tDC\tF'");                    \
  1121.       output_addr_const (FILE, EXP);                    \
  1122.       fprintf (FILE, "'\n");                        \
  1123.     }                                    \
  1124.   else                                    \
  1125.     {                                    \
  1126.       fprintf (FILE, "\tDC\tA(");                    \
  1127.       output_addr_const (FILE, EXP);                    \
  1128.       fprintf (FILE, ")\n");                        \
  1129.     }                                    \
  1130. }
  1131.  
  1132. /* This outputs a short integer.  */
  1133.  
  1134. #define ASM_OUTPUT_SHORT(FILE, EXP)                    \
  1135. {                                    \
  1136.   fprintf (FILE, "\tDC\tH'");                        \
  1137.   output_addr_const (FILE, EXP);                    \
  1138.   fprintf (FILE, "'\n");                        \
  1139. }
  1140.  
  1141. /* This outputs a byte sized integer.  */
  1142.  
  1143. #define ASM_OUTPUT_CHAR(FILE, EXP)                    \
  1144.   fprintf (FILE, "\tDC\tX'%02X'\n", INTVAL (EXP) )
  1145.  
  1146. #define ASM_OUTPUT_BYTE(FILE, VALUE)                    \
  1147.   fprintf (FILE, "\tDC\tX'%02X'\n", VALUE)
  1148.  
  1149. /* This outputs a text string.  The string are chopped up to fit into
  1150.    an 80 byte record.  Also, control and special characters, interpreted
  1151.    by the IBM assembler, are output numerically.  */
  1152.  
  1153. #define MVS_ASCII_TEXT_LENGTH 48
  1154.  
  1155. #define ASM_OUTPUT_ASCII(FILE, PTR, LEN)                \
  1156. {                                    \
  1157.   int i, j;                                \
  1158.   int c;                                \
  1159.   for (j = 0, i = 0; i < LEN; j++, i++)                    \
  1160.     {                                    \
  1161.       c = PTR[i];                            \
  1162.       if (iscntrl (c) || c == '&')                    \
  1163.     {                                \
  1164.       if (j % MVS_ASCII_TEXT_LENGTH != 0 )                \
  1165.         fprintf (FILE, "'\n");                    \
  1166.       j = -1;                            \
  1167.       if (c == '&') c = MAP_CHARACTER (c);                \
  1168.       fprintf (FILE, "\tDC\tX'%X'\n", c );                \
  1169.     }                                \
  1170.       else                                \
  1171.     {                                \
  1172.       if (j % MVS_ASCII_TEXT_LENGTH == 0)                \
  1173.             fprintf (FILE, "\tDC\tC'", c);                \
  1174.           if ( c == '\'' )                                           \
  1175.         fprintf (FILE, "%c%c", c, c);                            \
  1176.       else                                                       \
  1177.         fprintf (FILE, "%c", c);                                 \
  1178.       if (j % MVS_ASCII_TEXT_LENGTH == MVS_ASCII_TEXT_LENGTH - 1)    \
  1179.         fprintf (FILE, "'\n" );                    \
  1180.     }                                \
  1181.     }                                    \
  1182.   if (j % MVS_ASCII_TEXT_LENGTH != 0)                    \
  1183.     fprintf (FILE, "'\n");                        \
  1184. }
  1185.  
  1186. /* This is how to output an assembler line that says to advance the
  1187.    location counter to a multiple of 2**LOG bytes.  */
  1188.  
  1189. #define ASM_OUTPUT_ALIGN(FILE, LOG)                    \
  1190.   if (LOG)                                \
  1191.     {                                    \
  1192.       if ((LOG) == 1)                            \
  1193.         fprintf (FILE, "\tDS\t0H\n" );                    \
  1194.       else                                 \
  1195.         fprintf (FILE, "\tDS\t0F\n" );                    \
  1196.     }                                    \
  1197.  
  1198. /* The maximum length of memory that the IBM assembler will allow in one
  1199.    DS operation.  */
  1200.  
  1201. #define MAX_CHUNK 32767
  1202.  
  1203. /* A C statement to output to the stdio stream FILE an assembler
  1204.    instruction to advance the location counter by SIZE bytes. Those
  1205.    bytes should be zero when loaded.  */
  1206.  
  1207. #define ASM_OUTPUT_SKIP(FILE, SIZE)                      \
  1208. {                                    \
  1209.   int s, k;                                \
  1210.   for (s = (SIZE); s > 0; s -= MAX_CHUNK)                \
  1211.     {                                    \
  1212.       if (s > MAX_CHUNK)                        \
  1213.     k = MAX_CHUNK;                            \
  1214.       else                                \
  1215.     k = s;                                \
  1216.       fprintf (FILE, "\tDS\tXL%d\n", k);                \
  1217.     }                                    \
  1218. }
  1219.  
  1220. /* A C statement (sans semicolon) to output to the stdio stream
  1221.    FILE the assembler definition of a common-label named NAME whose
  1222.    size is SIZE bytes.  The variable ROUNDED is the size rounded up
  1223.    to whatever alignment the caller wants.  */
  1224.  
  1225. #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)             \
  1226. {                                    \
  1227.   fputs ("\tENTRY\t", FILE);                        \
  1228.   assemble_name (FILE, NAME);                        \
  1229.   fputs ("\n", FILE);                            \
  1230.   fprintf (FILE, "\tDS\t0F\n");                        \
  1231.   ASM_OUTPUT_LABEL (FILE,NAME);                        \
  1232.   ASM_OUTPUT_SKIP (FILE,SIZE);                        \
  1233. }
  1234.  
  1235. /* A C statement (sans semicolon) to output to the stdio stream
  1236.    FILE the assembler definition of a local-common-label named NAME
  1237.    whose size is SIZE bytes.  The variable ROUNDED is the size
  1238.    rounded up to whatever alignment the caller wants.  */
  1239.  
  1240. #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)             \
  1241. {                                    \
  1242.   fprintf (FILE, "\tDS\t0F\n");                        \
  1243.   ASM_OUTPUT_LABEL (FILE,NAME);                        \
  1244.   ASM_OUTPUT_SKIP (FILE,SIZE);                        \
  1245. }
  1246.  
  1247. /* Store in OUTPUT a string (made with alloca) containing an
  1248.    assembler-name for a local static variable named NAME.
  1249.    LABELNO is an integer which is different for each call.  */
  1250.  
  1251. #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)          \
  1252. {                                    \
  1253.   (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10);            \
  1254.   sprintf ((OUTPUT), "%s%d", (NAME), (LABELNO));            \
  1255. }
  1256.  
  1257. /* Define the parentheses used to group arithmetic operations
  1258.    in assembler code.  */
  1259.  
  1260. #define ASM_OPEN_PAREN "("
  1261. #define ASM_CLOSE_PAREN ")"
  1262.  
  1263. /* Define results of standard character escape sequences.  */
  1264.  
  1265. #define TARGET_BELL    47
  1266. #define TARGET_BS    22
  1267. #define TARGET_TAB    5
  1268. #define TARGET_NEWLINE    21
  1269. #define TARGET_VT    11
  1270. #define TARGET_FF    12
  1271. #define TARGET_CR    13
  1272.  
  1273. /* Print operand X (an rtx) in assembler syntax to file FILE.
  1274.    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
  1275.    For `%' followed by punctuation, CODE is the punctuation and X is null.  */
  1276.  
  1277. #define PRINT_OPERAND(FILE, X, CODE)                    \
  1278. {                                    \
  1279.   switch (GET_CODE (X))                            \
  1280.     {                                    \
  1281.       static char curreg[4];                        \
  1282.       case REG:                                \
  1283.     if (CODE == 'N')                        \
  1284.         strcpy (curreg, reg_names[REGNO (X) + 1]);            \
  1285.     else                                \
  1286.         strcpy (curreg, reg_names[REGNO (X)]);            \
  1287.     fprintf (FILE, "%s", curreg);                    \
  1288.     break;                                \
  1289.       case MEM:                                \
  1290.     {                                \
  1291.       rtx addr = XEXP (X, 0);                    \
  1292.       if (CODE == 'O')                        \
  1293.         {                                \
  1294.           if (GET_CODE (addr) == PLUS)                \
  1295.         fprintf (FILE, "%d", INTVAL (XEXP (addr, 1)));        \
  1296.           else                            \
  1297.         fprintf (FILE, "0");                    \
  1298.         }                                \
  1299.       else if (CODE == 'R')                        \
  1300.         {                                \
  1301.           if (GET_CODE (addr) == PLUS)                \
  1302.         fprintf (FILE, "%s", reg_names[REGNO (XEXP (addr, 0))]);\
  1303.           else                            \
  1304.         fprintf (FILE, "%s", reg_names[REGNO (addr)]);        \
  1305.         }                                \
  1306.       else                                \
  1307.         output_address (XEXP (X, 0));                \
  1308.     }                                \
  1309.     break;                                \
  1310.       case SYMBOL_REF:                            \
  1311.       case LABEL_REF:                            \
  1312.     mvs_page_lit += 4;                        \
  1313.     if (SYMBOL_REF_FLAG (X)) fprintf (FILE, "=V(");            \
  1314.     else                     fprintf (FILE, "=A(");            \
  1315.     output_addr_const (FILE, X);                    \
  1316.     fprintf (FILE, ")");                        \
  1317.     break;                                \
  1318.       case CONST_INT:                                \
  1319.     if (CODE == 'B')                        \
  1320.       fprintf (FILE, "%d", INTVAL (X) & 0xff);            \
  1321.     else if (CODE == 'X')                        \
  1322.       fprintf (FILE, "%02X", INTVAL (X) & 0xff);            \
  1323.     else if (CODE == 'h')                        \
  1324.       fprintf (FILE, "%d", (INTVAL (X) << 16) >> 16);        \
  1325.     else if (CODE == 'H')                        \
  1326.       {                                \
  1327.         mvs_page_lit += 4;                        \
  1328.         fprintf (FILE, "=F'%d'", (INTVAL (X) << 16) >> 16);        \
  1329.       }                                \
  1330.     else                                \
  1331.       {                                \
  1332.         mvs_page_lit += 4;                        \
  1333.         fprintf (FILE, "=F'%d'", INTVAL (X));            \
  1334.       }                                \
  1335.     break;                                \
  1336.       case CONST_DOUBLE:                        \
  1337.     if (GET_MODE (X) == DImode)                    \
  1338.       {                                \
  1339.         if (CODE == 'M')                        \
  1340.           {                                \
  1341.         mvs_page_lit += 4;                    \
  1342.         fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_LOW (X));    \
  1343.           }                                \
  1344.         else if (CODE == 'L')                    \
  1345.           {                                \
  1346.         mvs_page_lit += 4;                    \
  1347.         fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_HIGH (X));    \
  1348.           }                                \
  1349.         else                            \
  1350.           {                                \
  1351.         mvs_page_lit += 8;                    \
  1352.         fprintf (FILE, "=XL8'%08X%08X'", CONST_DOUBLE_LOW (X),    \
  1353.             CONST_DOUBLE_HIGH (X));                \
  1354.           }                                \
  1355.       }                                \
  1356.     else                                \
  1357.       {                                 \
  1358.         union { double d; int i[2]; } u;                \
  1359.         u.i[0] = CONST_DOUBLE_LOW (X);                \
  1360.         u.i[1] = CONST_DOUBLE_HIGH (X);                \
  1361.         if (GET_MODE (X) == SFmode)                    \
  1362.           {                                \
  1363.         mvs_page_lit += 4;                    \
  1364.         fprintf (FILE, "=E'%.9G'", u.d);            \
  1365.           }                                \
  1366.         else                            \
  1367.           {                                \
  1368.         mvs_page_lit += 8;                    \
  1369.         fprintf (FILE, "=D'%.18G'", u.d);            \
  1370.           }                                \
  1371.       }                                \
  1372.     break;                                \
  1373.       case CONST:                            \
  1374.     if (GET_CODE (XEXP (X, 0)) == PLUS                \
  1375.        && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)        \
  1376.       {                                \
  1377.         mvs_page_lit += 4;                        \
  1378.         if (SYMBOL_REF_FLAG (XEXP (XEXP (X, 0), 0)))        \
  1379.           {                                \
  1380.         fprintf (FILE, "=V(");                    \
  1381.         ASM_OUTPUT_LABELREF (FILE,                \
  1382.                   XSTR (XEXP (XEXP (X, 0), 0), 0));    \
  1383.         fprintf (FILE, ")\n\tA\t%s,=F'%d'", curreg,        \
  1384.                   INTVAL (XEXP (XEXP (X, 0), 1)));    \
  1385.           }                                \
  1386.         else                            \
  1387.           {                                \
  1388.         fprintf (FILE, "=A(");                    \
  1389.         output_addr_const (FILE, X);                \
  1390.         fprintf (FILE, ")");                    \
  1391.           }                                \
  1392.       }                                \
  1393.     else                                \
  1394.       {                                \
  1395.         mvs_page_lit += 4;                        \
  1396.         fprintf (FILE, "=F'");                    \
  1397.         output_addr_const (FILE, X);                \
  1398.         fprintf (FILE, "'");                    \
  1399.       }                                \
  1400.     break;                                \
  1401.       default:                                \
  1402.     abort();                            \
  1403.     }                                    \
  1404. }
  1405.  
  1406. #define PRINT_OPERAND_ADDRESS(FILE, ADDR)                \
  1407. {                                    \
  1408.   rtx breg, xreg, offset, plus;                        \
  1409.                                       \
  1410.   switch (GET_CODE (ADDR))                        \
  1411.     {                                    \
  1412.       case REG:                                \
  1413.     fprintf (FILE, "0(%s)", reg_names[REGNO (ADDR)]);        \
  1414.     break;                                \
  1415.       case PLUS:                            \
  1416.     breg = 0;                            \
  1417.     xreg = 0;                            \
  1418.     offset = 0;                            \
  1419.     if (GET_CODE (XEXP (ADDR, 0)) == PLUS)                \
  1420.       {                                \
  1421.         if (GET_CODE (XEXP (ADDR, 1)) == REG)            \
  1422.           breg = XEXP (ADDR, 1);                    \
  1423.         else                            \
  1424.           offset = XEXP (ADDR, 1);                    \
  1425.         plus = XEXP (ADDR, 0);                    \
  1426.       }                                \
  1427.     else                                \
  1428.       {                                \
  1429.         if (GET_CODE (XEXP (ADDR, 0)) == REG)            \
  1430.           breg = XEXP (ADDR, 0);                    \
  1431.         else                            \
  1432.           offset = XEXP (ADDR, 0);                    \
  1433.         plus = XEXP (ADDR, 1);                    \
  1434.       }                                \
  1435.     if (GET_CODE (plus) == PLUS)                    \
  1436.       {                                \
  1437.         if (GET_CODE (XEXP (plus, 0)) == REG)            \
  1438.           {                                \
  1439.         if (breg)                        \
  1440.           xreg = XEXP (plus, 0);                \
  1441.         else                            \
  1442.           breg = XEXP (plus, 0);                \
  1443.           }                                \
  1444.         else                            \
  1445.           {                                \
  1446.         offset = XEXP (plus, 0);                \
  1447.           }                                \
  1448.         if (GET_CODE (XEXP (plus, 1)) == REG)            \
  1449.           {                                \
  1450.         if (breg)                        \
  1451.           xreg = XEXP (plus, 1);                \
  1452.         else                            \
  1453.           breg = XEXP (plus, 1);                \
  1454.           }                                \
  1455.         else                            \
  1456.           {                                \
  1457.         offset = XEXP (plus, 1);                \
  1458.           }                                \
  1459.       }                                \
  1460.     else if (GET_CODE (plus) == REG)                \
  1461.       {                                \
  1462.         if (breg)                            \
  1463.           xreg = plus;                        \
  1464.         else                            \
  1465.           breg = plus;                        \
  1466.       }                                \
  1467.     else                                \
  1468.       {                                \
  1469.         offset = plus;                        \
  1470.       }                                \
  1471.     if (offset)                            \
  1472.       {                                \
  1473.         if (GET_CODE (offset) == LABEL_REF)                \
  1474.           fprintf (FILE, "L%d",                    \
  1475.             CODE_LABEL_NUMBER (XEXP (offset, 0)));        \
  1476.         else                            \
  1477.           output_addr_const (FILE, offset);                \
  1478.       }                                \
  1479.     else                                \
  1480.       fprintf (FILE, "0");                        \
  1481.     if (xreg)                            \
  1482.         fprintf (FILE, "(%s,%s)",                    \
  1483.             reg_names[REGNO (xreg)], reg_names[REGNO (breg)]);     \
  1484.     else                                \
  1485.       fprintf (FILE, "(%s)", reg_names[REGNO (breg)]);        \
  1486.     break;                                \
  1487.       default:                                \
  1488.     mvs_page_lit += 4;                        \
  1489.     if (SYMBOL_REF_FLAG (ADDR)) fprintf (FILE, "=V(");        \
  1490.     else                        fprintf (FILE, "=A(");        \
  1491.     output_addr_const (FILE, ADDR);                    \
  1492.     fprintf (FILE, ")");                        \
  1493.     break;                                \
  1494.     }                                    \
  1495. }
  1496.